package com.atguigu.guli.service.edu.controller.admin;


import com.atguigu.guli.service.base.result.R;
import com.atguigu.guli.service.edu.entity.Video;
import com.atguigu.guli.service.edu.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author atguigu
 * @since 2021-07-27
 */

@RestController
@RequestMapping("/admin/edu/video")
public class AdminVideoController {
    @Autowired
    VideoService videoService;
    //1、新增课时
    @PostMapping("save")
    public R save(@RequestBody Video video){
        videoService.save(video);
        return R.ok();
    }
    //2、删除课时
    @DeleteMapping("remove/{id}")
    public R remove(@PathVariable String id){
        videoService.removeById(id);
        return R.ok();
    }
    //3、根据id查询课时
    @GetMapping("getById/{id}")
    public R getById(@PathVariable String id){
        Video video = videoService.getById(id);
        return R.ok().data("item",video);
    }
    //4、更新课时
    @PutMapping("update")
    public R update(@RequestBody Video video){
        videoService.updateById(video);

        return R.ok();
    }
}

